package com.example.springs;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class Springs extends  SpringUtil {
    public static Object getBean(String name) {
        return getContext().getBean(name);
    }
    public static <T> T getBean(Class<T> type){
        return getContext().getBean(type);
    }
    //获取当前请求的httpservletresponse和request
    public static HttpServletRequest getReq()
    {
        return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    }

}
